package com.sportschain.app.shop.activity;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sportschain.app.R;
import com.sportschain.app.core.base.BaseActivity;
import com.sportschain.app.core.widget.MyToolbar;
import com.sportschain.app.shop.adapter.StoreActAdapter;
import com.sportschain.app.shop.adapter.UnionActAdapter;
import com.sportschain.app.shop.bean.StoreActBean;
import com.sportschain.app.shop.bean.UnionActBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class ActListActivity extends BaseActivity {


    public static final int MODE_STORE = 0;
    public static final int MODE_UNION = 1;
    @BindView(R.id.tool_bar)
    MyToolbar mToolBar;
    @BindView(R.id.act_rv)
    RecyclerView mActRv;

    private BaseQuickAdapter mAdapter;

    private int mMode = MODE_STORE;

    @Override
    public int getLayoutId() {
        return R.layout.activity_act_list;
    }

    @Override
    public void initView() {
        mMode = getIntent().getIntExtra("mode", MODE_STORE);
        if (mMode == MODE_STORE) {
            mToolBar.setTitle("商家活动");
            mAdapter = new StoreActAdapter();
        } else if (mMode == MODE_UNION) {
            mToolBar.setTitle("联合活动");
            mAdapter = new UnionActAdapter();
        }

        mAdapter.bindToRecyclerView(mActRv);
        mAdapter.setEmptyView(R.layout.empty_view_layout);
    }

    @Override
    public void initData() {
        List data = new ArrayList();
        for (int i = 0; i < 10; i++) {
            if (mMode == MODE_STORE) {
                data.add(new StoreActBean());
            } else if (mMode == MODE_UNION) {
                data.add(new UnionActBean());
            }
        }
        mAdapter.setNewData(data);
    }

    @Override
    public void initListener() {
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(StoreDetailActivity.class);
            }
        });
    }
}
